<?php

declare(strict_types=1);

namespace app\index\controller;

use addons\V2\admin\model\ProductCate;
use addons\WeChat\facade\WeChat;
use app\common\model\Carousel;
use think\facade\Cache;
use think\facade\View;

class Index extends Base
{
    public function index()
    {
        if (!isset($_GET['code'])) {
            $call_url = 'https://' . $_SERVER['SERVER_NAME'];
            $url = WeChat::getOauthRedirect($call_url, '', 'snsapi_base');
            header("Location:" . $url);
            exit;
        }
        return View::fetch();
    }

    public function communal()
    {
        $type = $this->request->param('type');
        $title = ['privacy_msg' => '注册协议'];

        View::assign([
            'title'   => $title[$type],
            'content' => Cache::get('system')[$type]
        ]);
        return View::fetch();
    }
}
